package com.xgsm.Controllers;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xgsm.Dao.UserDao;
import com.xgsm.entity.User;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2022/6/22.
 */

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserDao userDao;


    @RequestMapping("/list")
    public User contextLoads() {
        System.out.println(("----- selectAll method test ------"));
        List<User> userList = userDao.selectList(null);
        System.out.println("--------------------------------------");
        User user = userDao.selectById(1);
        System.out.println(userList);
        return user;
    }

    @RequestMapping("/page")
    public void userPagelist() {
//创建一个page对象
        Page<User> page = new Page<>();
        userDao.selectPage(page,null);
        System.out.println(page.getCurrent());//获取当前页
        System.out.println(page.getTotal());//获取总记录数
        System.out.println(page.getPages());//获取总页数

    }
}
